package com.hujing.mq.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {
    
    @Autowired
    private RabbitTemplate rabbitTemplate;
    
    @PostMapping("/sendMsg")
    public String sendMsg(){
        String message = "测试消息";
        rabbitTemplate.convertAndSend("testExchange","234",message);
        return "发送成功";
    }

    @PostMapping("/sendMsg2")
    public String sendMsg2(){
        String message = "测试消息";
        rabbitTemplate.convertAndSend("testExchange","567",message);
        return "发送成功";
    }
}
